package com.powersystem.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.powersystem.demo.entity.PsRole;
import com.powersystem.demo.mapper.PsRoleMapper;
import com.powersystem.demo.service.IPsRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author linrongji
 * @since 2019-11-14
 */
@Service
public class PsRoleServiceImpl extends ServiceImpl<PsRoleMapper, PsRole> implements IPsRoleService {
    @Autowired
    private PsRoleMapper PsRoleMapper;
    @Override
    public PsRole fetchByRoleNameAndIsstart(String roleName, int isstart) {
        return PsRoleMapper.fetchByRoleNameAndIsstart(roleName,isstart);
    }

    @Override
    public PsRole fetchByRoleIdAndRoelName(String roleId, String roleName) {
        return PsRoleMapper.fetchByRoleIdAndRoelName(roleId,roleName);
    }

    public IPage<PsRole> selectPageVo(String lineCode, int isStart, int page){
        Page<PsRole> pages = new Page<>(page, 5);
        return  PsRoleMapper.selectPage(pages, new QueryWrapper<PsRole>()
                .like("roleName", lineCode).like("isStart", isStart));
    }
}
